﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenWaves.Web.ImageTransformations
{
    [ContractClass(typeof(FileStoreContract))]
    public interface IFileStore
    {
        Url GetFileUrl(string fileName);
        bool FileExists(string fileName);
        Stream CreateFile(string fileName);
        void DeleteFile(string fileName);
    }

    [ContractClassFor(typeof(IFileStore))]
    abstract class FileStoreContract : IFileStore
    {
        public Url GetFileUrl(string fileName)
        {
            Contract.Requires<ArgumentNullException>(String.IsNullOrEmpty(fileName) == false);
            Contract.Ensures(Contract.Result<Url>() != null);

            throw new NotImplementedException();
        }

        public bool FileExists(string fileName)
        {
            Contract.Requires<ArgumentNullException>(String.IsNullOrEmpty(fileName) == false);
            throw new NotImplementedException();
        }

        public Stream CreateFile(string fileName)
        {
            Contract.Requires<ArgumentNullException>(String.IsNullOrEmpty(fileName) == false);
            Contract.Ensures(Contract.Result<Stream>() != null);

            throw new NotImplementedException();
        }

        public void DeleteFile(string fileName)
        {
            Contract.Requires<ArgumentNullException>(String.IsNullOrEmpty(fileName) == false);
            throw new NotImplementedException();
        }
    }
}